﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mammoth.Services;

namespace Mammoth.Entities
{
    public enum EventItemType
    {
        Error, Inbox, Outbox, Subscription
    }

    public abstract class EventItemEntity : Entity
    {
        public virtual EventItemType Type { get; set; }
        public virtual string Title { get; set; }
        public virtual string BuddyEmail { get; set; }
        public virtual string Message { get; set; }
        public virtual string ServiceEmail { get; set; }
    }

    public class ErrorEventItemEntity: EventItemEntity
    {
        public ErrorEventItemEntity(string message)
        {
            Type = EventItemType.Error;
            Title = "Galat";
            Message = message;
        }
    }

    public class InboxEventItemEntity: EventItemEntity
    {
        public InboxEventItemEntity(string serviceEmail, InboxEntity msg) : this(serviceEmail, msg.Buddy.Email, msg.Message) { }
        public InboxEventItemEntity(string serviceEmail, string buddyEmail, string message)
        {
            Type = EventItemType.Inbox;
            Title = "Pesan Masuk";
            BuddyEmail = buddyEmail;
            ServiceEmail = serviceEmail;
            Message = string.Format("{2} dari {0} untuk {1}", 
                buddyEmail, serviceEmail, message);
        }
    }

    public class OutboxEventEntity : EventItemEntity
    {
        public OutboxEventEntity(string serviceEmail, OutboxEntity msg) : this(serviceEmail, msg.Buddy.Email, msg.Message) { }
        public OutboxEventEntity(string serviceEmail, string buddyEmail, string message)
        {
            Type = EventItemType.Outbox;
            Title = "Pesan Keluar";
            BuddyEmail = buddyEmail;
            ServiceEmail = serviceEmail;
            Message = string.Format("{2} dari {0} untuk {1}",
                serviceEmail, buddyEmail, message);
        }
    }

    public class SubscriptionEventItemEntity : EventItemEntity
    {
        public SubscriptionEventItemEntity(string serviceEmail, string buddyEmail)
        {
            Type = EventItemType.Subscription;
            Title = "Permintaan langganan";
            BuddyEmail = buddyEmail;
            ServiceEmail = serviceEmail;
            Message = string.Format("Dari {0} untuk {1}", buddyEmail, serviceEmail);
        }
    }

}
